package utils

import (
	"github.com/medama-io/go-useragent"
)

func ReverseString(str string) string {
	if str == "" {
		return ""
	}

	runes := []rune(str)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func ParseUserAgent(ua string) (os, browser, device string) {
	parser := useragent.NewParser()

	userAgent := parser.Parse(ua)

	os = userAgent.GetOS()

	browser = userAgent.GetBrowser()

	device = userAgent.GetDevice()

	return

	// majorVersion := userAgent.GetMajorVersion()

	// version := userAgent.GetVersion()

	//fmt.Println(os, browser, device, majorVersion, version)
}
